#include <stdio.h>
#include <string.h>

typedef struct {
    int id;            // 学号
    char name[50];     // 姓名
    int age;           // 年龄
    int scores[5];     // 成绩数组，假设有5门课
} Student;
// 查找函数，按姓名和年龄范围查找
void findStudents(Student students[], int size, const char* name, int minAge, int maxAge) {
    int found = 0;
    for (int i = 0; i < size; i++) {
        if (strcmp(students[i].name, name) == 0 && students[i].age >= minAge && students[i].age <= maxAge) {
            printf("Found Student: ID = %d, Name = %s, Age = %d\n", students[i].id, students[i].name, students[i].age);
            found = 1;
        }
    }
    if (!found) {
        printf("No student found matching criteria.\n");
    }
}

int main() {
    // 创建一个学生数组
    Student students[] = {
        {1, "John Doe", 20, {88, 77, 90, 85, 93}},
        {2, "Jane Smith", 22, {92, 81, 87, 90, 95}},
        {3, "Alice Johnson", 20, {85, 80, 78, 88, 90}},
        {4, "John Doe", 23, {75, 85, 82, 89, 87}}
    };
    int size = sizeof(students) / sizeof(students[0]);

    // 查找名为"John Doe"且年龄在21到24之间的学生
    findStudents(students, size, "John Doe", 21, 24);

    return 0;
}
